# Maintainer: Martell Malone <martell malone at g mail dot com>

_realname=box2d
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.3.1
pkgrel=2
pkgdesc="2D rigid body simulation library for games (mingw-w64)"
arch=('any')
url="https://www.box2d.org/"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/erincatto/Box2D/archive/v${pkgver}.tar.gz)
sha256sums=('75d62738b13d2836cd56647581b6e574d4005a6e077ddefa5d727d445d649752')
options=(staticlibs !buildflags !strip)

build() {

  mkdir -p "${srcdir}/build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBOX2D_INSTALL=ON \
    -DBOX2D_BUILD_SHARED=ON \
    -DBOX2D_BUILD_STATIC=ON \
    -DBOX2D_BUILD_EXAMPLES=OFF \
    ../Box2D-${pkgver}/Box2D

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR=${pkgdir} install
}
